#include<stdio.h>

int count = 0;

void hanoi(int n, char a, char b, char c)
{
    if(n == 1)
    {
        if((a - c ) == 1 ||(c - a) == 1)
        {
        	printf("%c To %c\n", a, c);
            count++; 
        }
        else 
        {
            count += 2;
            printf("%c To %c\n%c To %c\n", a, b, b, c);
        }
    }
    else 
    {
        hanoi(n-1, a, b, c);
        hanoi(1, a, c, b);
        hanoi(n-1, c, b, a);
        hanoi(1, b, a, c);
        hanoi(n-1, a, b, c);
    }
}

int main()
{
    int n = 0;
    char A = 'A',B = 'B',C = 'C';
    scanf("%d", &n);
    
    hanoi(n, A ,B ,C);
    
    printf("%d", count);
    
    return 0;
}
